import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';

export const columns: BasicColumn[] = [
   {
    title: '告警名称',
    dataIndex: 'alarmName'
   },
   {
    title: '设备编号',
    dataIndex: 'deviceNo'
   },
   {
    title: '设备名称',
    dataIndex: 'deviceName'
   },
   {
    title: '告警级别',
    dataIndex: 'alarmLevel_dictText'
   },
   {
    title: '设备数据',
    dataIndex: 'deviceData'
   },
   {
    title: '处理状态',
    dataIndex: 'logStatus_dictText'
   },
   {
    title: '告警时间',
    dataIndex: 'createTime'
   }
];

export const searchFormSchema: FormSchema[] = [
 
 {
    label: '告警名称',
    field: 'alarmName',
    component: 'Input'
  },
  {
    label: '告警等级',
    field: 'alarmLevel',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: "alarm_level",
    },
  },
  {
    label: '处理状态',
    field: 'logStatus',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: "log_status",
    },
  },
];

export const formSchema: FormSchema[] = [
  // TODO 主键隐藏字段，目前写死为ID
  {label: '', field: 'logId', component: 'InputNumber', show: false},
   { label: '', field: 'isEdit', component: 'InputNumber', show: false },
  {
    label: '告警配置ID',
    field: 'alarmId',
    component: 'Input',
    componentProps: {
      type: 'number',
    },
     rules: [{ required: true, message: "请输入告警配置ID" }],
    dynamicDisabled: ({ values }) => {
     if (values.isEdit != undefined && values.isEdit == true) {
       return true
     } else {
       return false
     }
    },
  },
  {
    label: '设备ID',
    field: 'deviceId',
    component: 'Input',
    componentProps: {
      type: 'number',
    },
     rules: [{ required: true, message: "请输入设备ID" }],
    dynamicDisabled: ({ values }) => {
      if (values.isEdit != undefined && values.isEdit == true) {
        return true
      } else {
        return false
      }
    },
  },
  {
    label: '设备数据',
    field: 'deviceData',
    component: 'Input',
      rules: [{ required: true, message: "请输入设备数据" }],
    dynamicDisabled: ({ values }) => {
      if (values.isEdit != undefined && values.isEdit == true) {
        return true
      } else {
        return false
      }
    },
  },
  {
    label: '告警记录状态',
    field: 'logStatus',
    component: 'Input',
    rules: [{ required: true, message: "请输入告警记录状态" }],
    dynamicDisabled: ({ values }) => {
      if (values.isEdit != undefined && values.isEdit == true) {
        return true
      } else {
        return false
      }
    },
  },
];
